﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.IO;

using Ultimus.OC;
using Ultimus.WFServer;

using System.Data.SqlClient;
//using System.Data.OracleClient;
using System.Data.OleDb;

using System.Net;
using System.Diagnostics;

/// <summary>
/// Class1 的摘要说明
/// </summary>
namespace UltimusCommon
{
    public class UltCommon
    {
        public UltCommon()
        {
        }

        //这个对象只能使用在除流程开始步骤外的其他步骤
        public Ultimus.WFServer.Task ContextTask;

        //这个方法里记录常用的task的属性和方法。在流程除第一个步骤外的其他步骤这些属性是可以直接使用的
        public void Example()
        {
            string nIncidentNo = ContextTask.nIncidentNo.ToString();           //实例号
            string strTaskId = ContextTask.strTaskId;               //流程taskid

            string strProcessName = ContextTask.strProcessName;     //流程名称            
            string strStepName = ContextTask.strStepName;           //步骤名
            string strSummary = ContextTask.strSummary;             //流程摘要

            string strUserLogid = ContextTask.strUser;                  //流程处理人logid
            string strUserFullName = ContextTask.strUserFullName;       //流程处理人姓名
            string strAssignedToUser = ContextTask.strAssignedToUser;   //指派人员
            string strAssignedToUserFullName = ContextTask.strAssignedToUserFullName;   //指派人姓名

            string strHelpUrl = ContextTask.strHelpUrl;             //帮助文档url

            //流程用时间
            double dStartTime = ContextTask.dStartTime;             //任务开始时间
            DateTime startTime = DateTime.FromOADate(Convert.ToDouble(dStartTime));
            double dEndTime = ContextTask.dEndTime;                 //任务结束时间
            DateTime endTime = DateTime.FromOADate(Convert.ToDouble(dEndTime));
            double dOverdueTime = ContextTask.dOverDueTime;         //完成时限
            DateTime overdueTime = DateTime.FromOADate(Convert.ToDouble(dOverdueTime));
            double dDelayTime = ContextTask.dDelayTime;             //延迟时限
            DateTime delayTime = DateTime.FromOADate(Convert.ToDouble(dDelayTime));
            double dUrgentTime = ContextTask.dUrgentTime;          //宽延时限
            DateTime urgentTime = DateTime.FromOADate(Convert.ToDouble(dUrgentTime));


            //方法
            //设置变量的方法(多行、单个)
            //ContextTask.SetVariableValues("strVariableName", object[3], out string_1);
            //ContextTask.SetVariableValue
            //发送表单
            //ContextTask.SendFrom
            //ContextTask.Send
            //获取变量(多行、单个)
            //ContextTask.GetVariableValues("strVariableName", out new object[3], out "strError");
            //ContextTask.GetVariableValue


        }

        /// <summary>
        /// 得到数据库连接字符串，cs方法用的数据库链接字符串是统一放在C:\ConnDBStr.txt文件中的
        /// </summary>
        /// <returns>字符串标识</returns>
        public string GetConnStr(string pDBName)
        {
            UltimusWindowEventLog log = new UltimusWindowEventLog();
            
            System.Data.DataSet Ds = new System.Data.DataSet();
            try
            {
                Ds.ReadXml(@"C:\Program Files\Ultimus BPM Suite 7.1\Resources\Config.xml");
                if (Ds != null && Ds.Tables["setItem"].Rows.Count > 0)
                {
                    return (Ds.Tables["setItem"].Rows[0][pDBName].ToString());
                }
                else
                {
                    //log.Info("UltimusCommon.cs", "GetConnStr：服务组件读取\"" + pDBName + "\"信息失败！", ee.Message);
                    return "";
                }
            }
            catch (Exception ee)
            {
                log.Info("UltimusCommon", "GetConnStr", ee.Message);
                return "";
            }
        }

        /// <summary>
        /// 得到服务器端时间，每次都使用最新的服务器时间
        /// </summary>
        /// <param name="pNowTime">要返回的时间变量</param>
        public void GetServerTime(ref string pNowTime)
        {
            pNowTime = DateTime.Now.ToString();
        }
        /// <summary>
        /// 得到服务器端时间，如果传入的时间变量没有值就获取，有则不做处理
        /// </summary>
        /// <param name="pNowTime">要返回的时间变量</param>
        public void GetServerTime_1(ref string pNowTime)
        {
            if (pNowTime == null || pNowTime.Trim() == "")
            {
                pNowTime = DateTime.Now.ToString();
            }
        }

        /// <summary>
        /// 得到流程实例唯一标识
        /// </summary>
        /// <param name="Guid">GUID</param>
        public void GetGuid(ref string pGuid)
        {
            if (pGuid == null || pGuid.Trim() == "")
            {
                pGuid = Guid.NewGuid().ToString();
            }
        }

        /// <summary>
        /// 获取用户全名（从Ultimus系统库中）
        /// </summary>
        /// <param name="UserName">用户名（形式如：hyvachina.com/chenzheng）</param>
        /// <param name="FullName">返回用户的全名（如：陈震）</param>
        public void GetUserFullName(string userShortName, ref string userFullName)
        {
            userFullName = "";
            try
            {
                Ultimus.OC.OrgChart oreChart = new OrgChart();//定义OrgChart
                Ultimus.OC.User ocUser = new User();
                oreChart.FindUser(userShortName, "", 0, out ocUser);//查找全名为：userFullName 的用户，并将其存入 ocUser中；
                userFullName = ocUser.strUserFullName;
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetUserFullName", ee.Message); 
            }
        }
       
        /// <summary>
        /// 根据用户名获得职务
        /// </summary>
        /// <param name="userShortName">用户名</param>
        /// <param name="userJobFunction">职务名</param>
        public void GetJobFunction(string userShortName, ref string userJobFunction)
        {
            userJobFunction = "";
            try
            {
                Ultimus.OC.OrgChart oreChart = new OrgChart();//定义OrgChart
                Ultimus.OC.User ocUser = new User();
                oreChart.FindUser(userShortName, "", 0, out ocUser);//查找全名为：userFullName 的用户，并将其存入 ocUser中；
                userJobFunction = ocUser.strJobFunction;
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetJobFunction", ee.Message); ;
            }
        }

     
        /// <summary>
        /// 根据用户名获得所在部门
        /// </summary>
        /// <param name="userShortName">用户名</param>
        /// <param name="userDepartmentName">部门名</param>
        public void GetDepartmentName(string userShortName, ref string userDepartmentName)
        {
            userDepartmentName = "";
            try
            {
                Ultimus.OC.OrgChart oreChart = new OrgChart();//定义OrgChart
                Ultimus.OC.User ocUser = new User();
                oreChart.FindUser(userShortName, "", 0, out ocUser);//查找全名为：userFullName 的用户，并将其存入 ocUser中；
                userDepartmentName = ocUser.strDepartmentName;
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetDepartmentName", ee.Message); ;
            }
        }

        /// <summary>
        /// 根据当前登录人，获取部门一把手短用户名（标准组织结构，非标的需要测试或调试）
        /// </summary>
        /// <param name="userShortName">短用户名（*/*的形式）</param>
        /// <param name="depManagerShortName">部门一把手短用户名（*/*的形式）</param>
        public void GetDepManagerByShortName(string userShortName, ref string depManagerShortName)
        {
            depManagerShortName = "";
            try
            {
                Ultimus.OC.OrgChart oc = new OrgChart();
                Ultimus.OC.User user = new User();
                oc.FindUser(userShortName, "", 0, out user);
                if (user != null)
                {
                    string strDepartmentName = user.strDepartmentName.Trim();                   //获取到部门名称
                    GetDepManagerShortNameByDepName(strDepartmentName, ref depManagerShortName);  //调用本类中的方法，根据部门名称获取部门高层领导短用户名的方法
                }
                else
                {
                    depManagerShortName = "Error";
                }
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetDepManagerByShortName", ee.Message); ;
            }
        }

        /// <summary>
        /// 根据当前登录人，获取部门一把手短用户名及全名（标准组织结构，非标的需要测试或调试）
        /// </summary>
        /// <param name="userShortName">短用户名（*/*的形式）</param>
        /// <param name="depManagerShortName">部门一把手短用户名（*/*的形式）</param>
        /// <param name="depManagerFullName">部门一把手全名</param>
        public void GetDepManagerNamesByShortName(string userShortName, ref string depManagerShortName, ref string depManagerFullName)
        {
            depManagerShortName = "";
            depManagerFullName = "";
            try
            {
                Ultimus.OC.OrgChart oc = new OrgChart();
                Ultimus.OC.User user = new User();
                oc.FindUser(userShortName, "", 0, out user);
                if (user != null)
                {
                    string strDepartmentName = user.strDepartmentName.Trim();                   //获取到部门名称

                    //调用本类中的方法，根据部门名称获取部门高层领导短用户名及全名的方法
                    GetDepManagerNamesByDepName(strDepartmentName, ref depManagerShortName, ref  depManagerFullName);
                }
                else
                {
                    depManagerShortName = "";
                    depManagerFullName = "";
                }
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetDepManagerByShortName", ee.Message); ;
            }
        }

        /// <summary>
        /// 根据部门名称获取部门一把手的方法（适用标准组织结构，非标的需要测试或调试）
        /// </summary>
        /// <param name="depName">部门名称</param>
        /// <param name="depManagerShortName">部门一把手短用户名（*/*的形式）</param>
        public void GetDepManagerShortNameByDepName(string depName, ref string depManagerShortName)
        {
            depManagerShortName = "";
            try
            {
                OrgChart oc = new OrgChart();
                Ultimus.OC.Department department = new Department();
                oc.FindDepartment(depName, "", out department);        //根据部门名称加载部门信息。
                User[] userlist = null;
                if (department != null)
                {
                    department.GetDepartmentMenagers(out userlist);    //获取部门领导的集合（标准组织结构中领导只有一个）
                }
                if (userlist != null)
                {
                    depManagerShortName = userlist[0].strUserName.Trim();
                }
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetDepManagerShortNameByDepName", ee.Message); ;
            }            
        }

        /// <summary>
        /// 根据部门名称，获取部门一把手短用户名及全名（标准组织结构，非标的需要测试或调试）
        /// </summary>
        /// <param name="depName">部门名称</param>
        /// <param name="depManagerShortName">部门一把手短用户名（*/*的形式）</param>
        ///  <param name="depManagerFullName">部门一把手全名</param>
        public void GetDepManagerNamesByDepName(string depName, ref string depManagerShortName, ref string depManagerFullName)
        {
            depManagerShortName = "";
            depManagerFullName = "";
            try
            {
                OrgChart oc = new OrgChart();
                Ultimus.OC.Department dep = new Department();
                oc.FindDepartment(depName, "", out dep);        //根据部门名称加载部门信息。
                User[] userlist = null;
                if (dep != null)
                {
                    dep.GetDepartmentMenagers(out userlist);    //获取部门领导的集合（标准组织结构中领导只有一个）
                }
                if (userlist != null)
                {
                    depManagerShortName = userlist[0].strUserName.Trim();
                    depManagerFullName = userlist[0].strUserFullName.Trim();
                }
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetDepManagerNamesByDepName", ee.Message); ;
            }   
           
        }

        /// <summary>
        /// 获取用户组中所有人员
        /// </summary>
        /// <param name="groupName">用户组名称</param>
        /// <param name="codes">短用户名集合</param>
        /// <param name="names">用户全名拼接的字符串形式</param>
        public void getGroupManbers(string groupName, ref string[] shortname, ref string strnames)
        {
            try
            {
                for (int i = 0; i < shortname.Length; i++)
                {
                    shortname[i] = "";
                }
                strnames = "";
                Ultimus.OC.OrgChart oc = new OrgChart();
                Ultimus.OC.Group group = new Group();
                oc.GetGroup(groupName, out group);
                if (group != null)
                {
                    for (int i = 0; i < group.GroupMembers.Length; i++)
                    {
                        shortname[i] = group.GroupMembers[i].strMemberName; //strMemberName就是shortName

                        if (strnames == "")
                        {
                            strnames = group.GroupMembers[i].strFullName;
                        }
                        else
                        {
                            strnames += "，" + group.GroupMembers[i].strFullName;
                        }
                        //group.GroupMembers[i].nWeight;        //是获取工作组成员的工作量设置，使用于工作量分配组
                        //group.GroupMembers[i].nSequence;      //是获取工作组成员的序列，适用于循序工作组
                    }
                }
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "getGroupManbers", ee.Message); ;
            }              
        }

        /// <summary>
        /// 获取用户的直属主管（从Ultimus系统库中）
        /// </summary>
        /// <param name="UserName">用户名（形式如：hyvachina.com/chenzheng）</param>
        /// <param name="SupervisorShortName">返回直属主管的用户名（形式如：hyvachina.com/chenzheng）</param>
        /// <param name="SupervisorFullName">返回直属主管的用户全名（如：陈震）</param>
        public void GetSupervisor(string UserName, ref string SupervisorShortName, ref string SupervisorFullName)
        {
            try
            {
                Ultimus.OC.OrgChart oreChart = new OrgChart();//定义OrgChart
                Ultimus.OC.User ocUser = new User();
                oreChart.FindUser(UserName, "", 0, out ocUser);//查找全名为：userFullName 的用户，并将其存入 ocUser中；
              

                ocUser.GetSupervisor(out SupervisorShortName);   //（总监、或执行董事、事业部总经理等）直接管理的人员，这些人员不在具体的部门中  、、、以及各部门部长的登录id
                Ultimus.OC.User ocUser_Supervisor = new User();
                oreChart.FindUser(SupervisorShortName, "", 0, out ocUser_Supervisor);

                SupervisorFullName = ocUser_Supervisor.strUserFullName;
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetSupervisor", ee.Message); 
            }   
        }

        /// <summary>
        /// 获取特定用户的邮箱
        /// </summary>
        /// <param name="userShortName">用户名</param>
        /// <param name="mailAddress">邮箱</param>
        public void GetUsermailAddress(string userShortName, ref string mailAddress)
        {
            mailAddress = "";
            try
            {
                Ultimus.OC.OrgChart oreChart = new OrgChart();//定义OrgChart
                Ultimus.OC.User ocUser = new User();
                UserPreferences userPre = new UserPreferences();
                oreChart.FindUser(userShortName, "", 0, out ocUser);//查找全名为：userFullName 的用户，并将其存入 ocUser中；
                ocUser.GetUserPrefs(out  userPre);//获取用户信息；
                mailAddress = userPre.strEmail;//获取用户的邮箱地址；
               
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetUsermailAddress", ee.Message); 
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="userShortName"></param>
        /// <param name="username"></param>
        /// <param name="strTel"></param>
        /// <param name="strEmail"></param>
        public void GetUser_FullName_Tel_Email(string userShortName, ref string strTel)
        {

           
            string strSql = "";
            try
            {

                string StrCon = GetConnStr("connString");


                SqlConnection conn = new SqlConnection(StrCon);
                conn.Open();

          
                strSql = " select user_mobile from USR_USER where USER_ULT_CODE= '" + userShortName + "'";
             
                SqlCommand comm1 = new SqlCommand(strSql, conn);
                SqlDataReader reader = comm1.ExecuteReader();

                while (reader.Read())
                {
                  
                    strTel = reader["user_mobile"].ToString();
                   
                }

                reader.Close();

                conn.Close();
            }
            catch (Exception e)
            {
               
            }
           
        }

        /// <summary>
        /// 获取某一部门特定职务的邮箱地址；
        /// </summary>
        /// <param name="departName">部门名</param>
        /// <param name="jobFunctions">职务名（多个职务用";"分隔）</param>
        /// <param name="mailList">邮箱，“;”号分隔的</param>
        public void GetDepartmentJobMembersMails(string departName, string jobFunctions, ref string mailList)
        {
            try
            {
                mailList = "";
                string mailTemp = "";
                string[] jobfunctionTemp = jobFunctions.Split(new char[] { ';' });
                Ultimus.OC.OrgChart oreChart = new OrgChart();//定义OrgChart
                Department department = new Department();
                Ultimus.OC.User[] ocUser = null;
                UserPreferences userPreferences = new UserPreferences();
                oreChart.FindDepartment(departName, "", out department);
                department.GetDepartmentMembers(out ocUser);
                if (ocUser.Length > 0)
                {
                    for (int i = 0; i < ocUser.Length; i++)
                    {
                        for (int j = 0; j < jobfunctionTemp.Length; j++)
                        {

                            if (ocUser[i].strJobFunction == jobfunctionTemp[j].Trim())
                            {
                                ocUser[i].GetUserPrefs(out userPreferences);
                                mailTemp = userPreferences.strEmail;
                                if (mailTemp != "")
                                {
                                    if (mailList == "")
                                    {
                                        mailList = mailTemp;
                                    }
                                    else
                                    {
                                        mailList = mailList + ";" + mailTemp;
                                    }
                                }
                                //break;
                            }
                        }
                    }
                }
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetDepartmentJobMembersMails", ee.Message);
            }            
        }

        /// <summary>
        /// 获取某一部门的所有员工的邮箱地址，“;”号分隔
        /// </summary>
        /// <param name="departName">部门名称</param>
        /// <param name="mailList">邮箱</param>
        public void GetDepartmentMembersMails(string departName, ref string mailList)
        {
            try
            {
                mailList = "";
                string mailTemp = "";
                Ultimus.OC.OrgChart oreChart = new OrgChart();//定义OrgChart
                Department department = new Department();
                Ultimus.OC.User[] ocUser = null;
                UserPreferences userPreferences = new UserPreferences();
                oreChart.FindDepartment(departName, "", out department);
                department.GetDepartmentMembers(out ocUser);
                if (ocUser.Length > 0)
                {
                    for (int i = 0; i < ocUser.Length; i++)
                    {
                        ocUser[i].GetUserPrefs(out userPreferences);
                        mailTemp = userPreferences.strEmail;
                        if (mailTemp != "")
                        {
                            if (mailList == "")
                            {
                                mailList = userPreferences.strEmail;

                            }
                            else
                            {
                                mailList = mailList + ";" + userPreferences.strEmail;
                            }
                        }

                    }

                }
            }
            catch (Exception ee)
            {
                UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetDepartmentMembersMails", ee.Message);
            }             
        }

        //获取表单的网址;
        public void GetFormUrl(string processName, string stepName, int inclientNumber, string userName, string http, ref string url, bool getUrlBool)
        {
            /* 参数说明: 
             * processName: 流程名
             * stepName: 步骤名
             * inclientNumber: 实例号
             * userName:域名/用户名
             * http: 服务器地址+其ultimus 虚拟目录;
             * url: 获取的表单网址
             * getUrlBool:操作是否成功,成功返回 true;否则返回false;
             * 注意事项:利用.Net机器人执行该代码.并且.Net机器人不要设置成(内嵌);
             */
            //调试日志
            UltimusWindowEventLog log = new UltimusWindowEventLog();
            log.Debug("UltimusCommon.cs", "GetFormUrl", "processName:" + processName + "####stepName:" + stepName + "####inclientNumber:" + inclientNumber + "###userName:" + userName + "###http:" + http);
            try
            {
                if (inclientNumber <= 0)
                {
                    getUrlBool = false;
                    return;
                }
                Ultimus.WFServer.Tasklist taskList = new Ultimus.WFServer.Tasklist();//任务列表实例对象;
                Ultimus.WFServer.Task task = new Ultimus.WFServer.Task();//任务实例;
                Ultimus.WFServer.TasklistFilter tasklistFilter = new Ultimus.WFServer.TasklistFilter();//任务过滤器;
                string[] userNames = new string[1];
                userNames[0] = userName.Trim().Replace("\\", "/");
                tasklistFilter.strArrUserName = userNames;
                tasklistFilter.strProcessNameFilter = processName.Trim();//流程名;
                tasklistFilter.nFiltersMask = Filters.nFilter_Current;//任务已实例化;
                tasklistFilter.nIncidentNo = inclientNumber;
                tasklistFilter.strStepLabelFilter = stepName.Trim();//步骤名;
                taskList.LoadFilteredTasks(tasklistFilter);//获取符合条件的任务;
                task = taskList.GetAt(0);
                if (task != null)
                {
                    string str = null;
                    task.ExtractFormURL(out str);
                    url = http + str.TrimStart(".".ToCharArray());
                    getUrlBool = true;
                }
                else
                {
                    getUrlBool = false;
                }
            }
            catch (Exception ee)
            {
                //UltimusWindowEventLog log = new UltimusWindowEventLog();
                log.Error("UltimusCommon.cs", "GetFormUrl", ee.Message);
            }
        }

        #region 不再使用的关于VerifyInfo的方法
        /// <summary>
        /// 插入审批信息
        /// </summary>
        /// <param name="username">用户全名</param>
        /// <param name="result">审批结果</param>
        /// <param name="memo">审批意见</param>
        public void insertVerifyInfo(string username, string result, string memo)
        {
            #region 建表语句
            //create table Usr_VerifyInfo 
            //(
            //    id                   numeric        IDENTITY(1,1)                not null,
            //    guid                 char(36),
            //    proName              varchar(200),
            //    incidentNum          varchar(20),
            //    doMan                varchar(200),
            //    "time"               datetime,
            //    result               varchar(200),
            //    memo                 varchar(2000),
            //    attachment           varchar(500),
            //    stepName             varchar(200),
            //    depName              varchar(200),
            //    constraint PK_Usr_VerifyInfo primary key clustered (id)
            //);
            #endregion
            string strIncident = ContextTask.nIncidentNo.ToString();//实例号
            string strProcess = ContextTask.strProcessName.ToString();  //流程名
            string strStep = ContextTask.strStepName.ToString();        //步骤名
            //string UserID = ContextTask.strAssignedToUser.ToString();		//用户登陆id
            object strGuid = "";
            string strError = "";
            ContextTask.GetVariableValue("GUID", out strGuid, out strError);
            SqlDBClass sqlDb = null;
            string sqlStr = "";
            try
            {
                string StrCon = GetConnStr("UserData");

                sqlDb = new SqlDBClass(StrCon);
                sqlDb.getConnect();//连接数据库； 
                sqlStr = "INSERT INTO Usr_VerifyInfo(proName,incidentNum,doMan,[time],result,memo,stepName,guid) VALUES ('" + strProcess + "','" + strIncident +
                    "','" + username + "','" + DateTime.Now.ToString() + "','" + result + "','" + memo + "','" + strStep + "','" + strGuid.ToString() + "')";
                sqlDb.exeSql(sqlStr);
                sqlDb.clear();

            }
            catch (Exception e)
            {
                //this.LogEx("获取审批意见", "GetVerifyInfo1", e.Message, sqlStr);
                //Log("", "异常信息" + e.Message + " || " + "sql语句" + sqlStr);
            }
            finally
            {
                if (sqlDb != null && sqlDb.Connection.State == System.Data.ConnectionState.Open)
                {
                    sqlDb.clear();//关闭连接；
                }
            }
        }

        /// <summary>
        ///  获取流程对应的审批信息
        /// </summary>
        /// <param name="person">处理人多行变量</param>
        /// <param name="result">处理结果多行变量</param>
        /// <param name="time">处理时间多行变量</param>
        /// <param name="memo">处理意见多行变量</param> 
        /// <param name="count">列表数量</param>
        public void GetVerifyInfo1(ref string[] person, ref string[] result, ref string[] time, ref string[] memo, ref string count)
        {
            #region 建表语句
            //create table Usr_VerifyInfo 
            //(
            //    id                   numeric        IDENTITY(1,1)                not null,
            //    guid                 char(36),
            //    proName              varchar(200),
            //    incidentNum          varchar(20),
            //    doMan                varchar(200),
            //    "time"               datetime,
            //    result               varchar(200),
            //    memo                 varchar(2000),
            //    attachment           varchar(500),
            //    stepName             varchar(200),
            //    depName              varchar(200),
            //    constraint PK_Usr_VerifyInfo primary key clustered (id)
            //);
            #endregion
            string strIncident = ContextTask.nIncidentNo.ToString();//实例号
            string strProcess = ContextTask.strProcessName.ToString();  //流程名
            SqlDBClass sqlDb = null;
            string sqlStr = "";
            try
            {
                string StrCon = GetConnStr("UserData");

                sqlDb = new SqlDBClass(StrCon);
                sqlDb.getConnect();//连接数据库； 
                sqlStr = "SELECT doMan,time,result,memo FROM Usr_VerifyInfo  where proName ='" + strProcess + "' and incidentNum='" + strIncident + "'";


                DataTable dt = sqlDb.GetDataTable(sqlStr);
                if (dt != null && dt.Rows.Count > 0)
                {
                    count = dt.Rows.Count.ToString();   //返回记录数

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        person[i] = dt.Rows[i]["doMan"].ToString();
                        result[i] = dt.Rows[i]["result"].ToString();
                        time[i] = dt.Rows[i]["time"].ToString();
                        memo[i] = dt.Rows[i]["memo"].ToString();
                    }
                }
                sqlDb.clear();//关闭连接；sql

            }
            catch (Exception e)
            {
                //this.LogEx("获取审批意见", "GetVerifyInfo1", e.Message, sqlStr);
                //Log("", "异常信息" + e.Message + " || " + "sql语句" + sqlStr);
            }
            finally
            {
                if (sqlDb != null && sqlDb.Connection.State == System.Data.ConnectionState.Open)
                {
                    sqlDb.clear();//关闭连接；
                }
            }
        }


        /// <summary>
        ///  获取流程对应的审批信息
        /// </summary>
        /// <param name="person">处理人多行变量</param>
        /// <param name="result">处理结果多行变量</param>
        /// <param name="time">处理时间多行变量</param>
        /// <param name="memo">处理意见多行变量</param> 
        /// <param name="stepname">步骤名</param>
        /// <param name="count">列表数量</param>
        public void GetVerifyInfo2(ref string[] person, ref string[] result, ref string[] time, ref string[] memo, ref string[] stepname, ref string count)
        {
            #region 建表语句
            //create table Usr_VerifyInfo 
            //(
            //    id                   numeric        IDENTITY(1,1)                not null,
            //    guid                 char(36),
            //    proName              varchar(200),
            //    incidentNum          varchar(20),
            //    doMan                varchar(200),
            //    "time"               datetime,
            //    result               varchar(200),
            //    memo                 varchar(2000),
            //    attachment           varchar(500),
            //    stepName             varchar(200),
            //    depName              varchar(200),
            //    constraint PK_Usr_VerifyInfo primary key clustered (id)
            //);
            #endregion
            string strIncident = ContextTask.nIncidentNo.ToString();//实例号
            string strProcess = ContextTask.strProcessName.ToString();  //流程名
            SqlDBClass sqlDb = null;
            string sqlStr = "";
            try
            {
                string StrCon = GetConnStr("UserData");

                sqlDb = new SqlDBClass(StrCon);
                sqlDb.getConnect();//连接数据库； 
                sqlStr = "SELECT doMan,time,result,memo,stepname FROM Usr_VerifyInfo  where proName ='" + strProcess + "' and incidentNum='" + strIncident + "'";


                DataTable dt = sqlDb.GetDataTable(sqlStr);
                if (dt != null && dt.Rows.Count > 0)
                {
                    count = dt.Rows.Count.ToString();   //返回记录数

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        person[i] = dt.Rows[i]["doMan"].ToString();
                        result[i] = dt.Rows[i]["result"].ToString();
                        time[i] = dt.Rows[i]["time"].ToString();
                        memo[i] = dt.Rows[i]["memo"].ToString();
                        stepname[i] = dt.Rows[i]["stepname"].ToString();
                    }
                }
                sqlDb.clear();//关闭连接；sql

            }
            catch (Exception e)
            {
                //this.LogEx("获取审批意见", "GetVerifyInfo1", e.Message, sqlStr);
               // Log("", "异常信息" + e.Message + " || " + "sql语句" + sqlStr);
            }
            finally
            {
                if (sqlDb != null && sqlDb.Connection.State == System.Data.ConnectionState.Open)
                {
                    sqlDb.clear();//关闭连接；
                }
            }
        }

        #endregion

        /// <summary>
        /// 插入审批信息
        /// </summary>
        /// <param name="username">用户全名</param>
        /// <param name="result">审批结果</param>
        /// <param name="memo">审批意见</param>
        public void InsertShenpiEx(string username, string strResult, string Content, ref string strError)
        {
            string strIncident = ContextTask.nIncidentNo.ToString();//实例号
            string strProcess = ContextTask.strProcessName.ToString();  //流程名
            string strStep = ContextTask.strStepName.ToString();        //步骤名
            //string UserID = ContextTask.strAssignedToUser.ToString();		//用户登陆id
            object strGuid = "";
            ContextTask.GetVariableValue("GUID", out strGuid, out strError);
            SqlDBClass sqlDb = null;
            string sqlStr = "";
            try
            {
                string StrCon = GetConnStr("connString");

                sqlDb = new SqlDBClass(StrCon);
                sqlDb.getConnect();//连接数据库； 
                sqlStr = "insert into fw_shenpi (guid,process,steplabel,incident,userid,username,[datetime],result,notion) VALUES ('" + strProcess + "','" + strIncident +
                    "','" + username + "','" + DateTime.Now.ToString() + "','" + strResult + "','" + Content + "','" + strStep + "','" + strGuid.ToString() + "')";
                sqlDb.exeSql(sqlStr);
                sqlDb.clear();

            }
            catch (Exception e)
            {
                //this.LogEx("获取审批意见", "GetVerifyInfo1", e.Message, sqlStr);
               // Log("", "异常信息" + e.Message + " || " + "sql语句" + sqlStr);
            }
            finally
            {
                if (sqlDb != null && sqlDb.Connection.State == System.Data.ConnectionState.Open)
                {
                    sqlDb.clear();//关闭连接；
                }
            }
        }

        /// <summary>
        /// 更新流程摘要
        /// </summary>
        /// <param name="str">要写到摘要的内容</param>
        /// <param name="summray">流程摘要</param>
        public void updateSummray(string str, ref string summray)
        {
            summray = str;
        }
        /// <summary>
        /// 通过输入标志信息，获取单号
        /// </summary>
        /// <param name="sign">获取流水号的标志（如报销：BX）</param>
        /// <param name="runingNum">返回单号</param>
        public void getRuningNum(string sign, ref string runingNum)
        {

            #region 建表语句
            //create table Usr_runningNum 
            //(
            //    sign                 varchar(100),
            //    year                 varchar(20),
            //    month                varchar(20),
            //    num                  decimal(18,0)
            //);
            #endregion

            string head = "ULT";                    //这里一般是写公司的缩写
            if (sign != null && sign != "")
            {
                DateTime time = DateTime.Now;
                string year = time.Year.ToString();       //获取当前时间的年份
                string month = time.Month.ToString();     //获取当前时间的月份

                SqlDBClass sqlDb = null;
                string sqlStr = "";
                try
                {
                    string StrCon = GetConnStr("bpmDate");

                    sqlDb = new SqlDBClass(StrCon);
                    sqlDb.getConnect();//连接数据库； 
                    int num = 0;

                    #region 获取 尾数
                    sqlStr = "select num from Usr_runningNum where sign='" + sign + "' and year ='" + year + "' and month ='" + month + "'";
                    //Log("", "year:::aaa" + sqlStr);
                    DataTable dt = sqlDb.GetDataTable(sqlStr);
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        num = Convert.ToInt32(dt.Rows[0]["num"]);
                        num += 1;
                        sqlStr = "update Usr_runningNum set num = " + num + " where sign='" + sign + "' and year ='" + year + "' and month ='" + month + "'";
                        // Log("", "year:::yearbbb" + sqlStr);
                        sqlDb.exeSql(sqlStr);
                    }
                    else
                    {
                        //insert Usr_runningNum (sign,year,month,num) value ('','','',)
                        sqlStr = "insert Usr_runningNum (sign,year,month,num) values ('" + sign + "','" + year + "','" + month + "',1)";
                        // Log("", "year:::yearcccc" + sqlStr);
                        sqlDb.exeSql(sqlStr);
                        num = 1;
                    }
                    #endregion

                    #region 拼接字符串
                    if (num <= 9)
                    {
                        runingNum = head + sign + year + month + "000" + num;
                    }
                    else if (num <= 99)
                    {
                        runingNum = head + sign + year + month + "00" + num;
                    }
                    else if (num <= 999)
                    {
                        runingNum = head + sign + year + month + "0" + num;
                    }
                    else
                    {
                        runingNum = head + sign + year + month + num;
                    }
                    #endregion

                    sqlDb.clear();//关闭连接；sql
                }
                catch (Exception e)
                {
                    //Log("", "异常信息" + e.Message + " || " + "sql语句" + sqlStr);
                }
                finally
                {
                    if (sqlDb != null && sqlDb.Connection.State == System.Data.ConnectionState.Open)
                    {
                        sqlDb.clear();//关闭连接；
                    }
                }
            }
        }

        /// <summary>
        /// 插入阅知记录
        /// </summary>
        /// <param name="PubUserName">发送阅知人姓名</param>
        /// <param name="userIds">接收阅知的人员ID组</param>
        public void InsertYueZhiUserCode(string PubuserName, string[] usercode)
        {
            #region 建表语句
            //create table Yw_ReadKnow          --阅知表
            //(
            //    RkId                 numeric          identity(1,1)              not null,
            //    flowName             varchar(200),
            //    stepName             varchar(200),
            //    InciId               numeric,
            //    pubuserCode          varchar(200),
            //    pubuserName          varchar(200),
            //    pubuserTime          datetime,
            //    Topic                varchar(1000),
            //    TaskId               varchar(200),
            //    status               varchar(10),
            //    constraint PK_HY_READKNOW primary key clustered (RkId)
            //);
            //create table Yw_ReadKnowLink      --关联表
            //(
            //    RUid                 numeric          identity(1,1)              not null,
            //    Rkid                 numeric,
            //    rkStatus             varchar(10),
            //    userId               varchar(20),
            //    userCode             varchar(200),
            //    constraint PK_HY_READKNOWLINK primary key clustered (RUid)
            //);
            #endregion

            #region 存储过程
            //CREATE PROCEDURE [dbo].[proc_Yw_ReadKnow_Insert] 
            //@RkId numeric output ,
            //@flowName varchar(200)  ,
            //@stepName varchar(200)  ,
            //@InciId numeric ,
            //@pubuserCode varchar(200)  ,
            //@pubuserName varchar(200)  ,
            //@pubuserTime datetime ,
            //@Topic varchar(1000)  ,
            //@TaskId varchar(200)  ,
            //@status varchar(10)  
            //as
            //insert [Hy_ReadKnow] (flowName,stepName,InciId,pubuserCode,pubuserName,pubuserTime,Topic,TaskId,status) 
            //values(@flowName,@stepName,@InciId,@pubuserCode,@pubuserName,@pubuserTime,@Topic,@TaskId,@status)
            //set @RkId=@@IDENTITY
            #endregion

            if (usercode == null) { return; }

            string strIncident = ContextTask.nIncidentNo.ToString();    //实例号
            string strProcess = ContextTask.strProcessName.ToString();  //流程名
            string strStep = ContextTask.strStepName.ToString();        //步骤名
            string PubuserCode = ContextTask.strAssignedToUser.ToString();	//用户登陆id
            string Topic = ContextTask.strSummary.ToString();           //流程摘要
            string strTaskID = ContextTask.strTaskId.ToString();        //taskid

            string sqlStr = "";
            string StrCon = GetConnStr("bpmDate");
            SqlConnection con = new SqlConnection(StrCon);
            Int32 rkid = 0;
            try
            {
                con.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "proc_yw_ReadKnow_Insert";
                cmd.Connection = con;
                SqlParameter sp1 = new SqlParameter("@RkId", rkid);
                sp1.Direction = ParameterDirection.InputOutput;
                cmd.Parameters.Add(sp1);
                SqlParameter sp2 = new SqlParameter("@flowName", strProcess);
                cmd.Parameters.Add(sp2);
                SqlParameter sp3 = new SqlParameter("@stepName", strStep);
                cmd.Parameters.Add(sp3);
                SqlParameter sp4 = new SqlParameter("@InciId", strIncident);
                cmd.Parameters.Add(sp4);
                SqlParameter sp5 = new SqlParameter("@pubuserCode", PubuserCode);
                cmd.Parameters.Add(sp5);
                SqlParameter sp6 = new SqlParameter("@pubuserName", PubuserName);
                cmd.Parameters.Add(sp6);
                SqlParameter sp7 = new SqlParameter("@pubuserTime", DateTime.Now.ToString());
                cmd.Parameters.Add(sp7);
                SqlParameter sp8 = new SqlParameter("@Topic", Topic);
                cmd.Parameters.Add(sp8);
                SqlParameter sp9 = new SqlParameter("@TaskId", strTaskID);
                cmd.Parameters.Add(sp9);
                SqlParameter sp10 = new SqlParameter("@status", "1");
                cmd.Parameters.Add(sp10);

                int count = cmd.ExecuteNonQuery();


                for (int i = 0; i < usercode.Length; i++)
                {
                    if (usercode[i] != null && usercode[i] != "")   //判断用户接收阅知的用户是否有值
                    {
                        sqlStr = "insert into hy_ReadKnowLink (Rkid,rkStatus,userCode) values (" + sp1.Value + ",'未查看','" + usercode[i] + "')";   //插入新的记录(关联表)
                        cmd = new SqlCommand(sqlStr, con);
                        cmd.ExecuteNonQuery();
                    }
                }
                cmd.Dispose();
                con.Close();
                con.Dispose();
            }
            catch (Exception e)
            {
               // Log("", "异常信息" + e.Message + " || " + "InsertYueZhiUserCode——sql语句" + sqlStr);
            }
            finally
            {
                con.Close();
                con.Dispose();
            }
        }

        /// <summary>
        /// 招商银行使用
        /// </summary>
        /// <param name="sendUserName">发送阅知人姓名</param>
        /// <param name="recUserID">阅知人ID</param>
        public void InsertReadKnow(string taskid,string sendUserName, string[] recUserID)
        {
            ContextTask = new Ultimus.WFServer.Task();
            bool flag = ContextTask.InitializeFromTaskId(taskid);
            if (flag)
            {
                string strIncident = ContextTask.nIncidentNo.ToString();//实例号
                string sendUserID = ContextTask.strAssignedToUser.ToString();		//用户工资号
                string strProcess = ContextTask.strProcessName.ToString();  //流程名
                string strStepName = ContextTask.strStepName.ToString();//步骤名称
                string strTaskID = ContextTask.strTaskId.ToString();        //taskid
                string strGetUserId = "";
                for (int i = 0; i < recUserID.Length; i++)
                {
                    strGetUserId += "'" + recUserID[i].ToString() + "',";
                }
                if (strGetUserId.EndsWith(","))
                {
                    strGetUserId = strGetUserId.Substring(0, strGetUserId.Length - 1);
                }
                if (strGetUserId.Length > 0)
                {
                    SqlDBClass sqlDb = null;
                    string strSql = "";
                    string insertRead = "";
                    try
                    {
                        string StrCon = GetConnStr("connString");
                        StrCon = StrCon.Replace("System.Data.SqlClient@@", "");
                        sqlDb = new SqlDBClass(StrCon);
                        sqlDb.getConnect();
                        string sendTime = DateTime.Now.ToString();
                        //查询该任务的taskID
                        strSql = "select tasks.processname,tasks.incident,incidents.summary,tasks.steplabel " +
                            " from tasks left join incidents on tasks.processname=incidents.processname and " +
                            " tasks.incident = incidents.incident where tasks.taskid='" + strTaskID + "'";
                        
                        //DataTable dt = gw.FromCustomSql(strSql).ToDataSet().Tables[0];
                        DataTable dt = sqlDb.GetDataTable(strSql);
                        if (dt.Rows.Count > 0)
                        {
                            strProcess = dt.Rows[0]["processname"].ToString();
                            strIncident = dt.Rows[0]["incident"].ToString();
                            strStepName = dt.Rows[0]["steplabel"].ToString();
                            string strSummary = dt.Rows[0]["summary"].ToString();
                            strSql = "select Rk_ID from usr_read_know where Prc_Name='" + strProcess +
                                "' and incident = " + strIncident;


                            dt = sqlDb.GetDataTable(strSql);
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                //获取记录ID
                                string strRkID = dt.Rows[0]["Rk_ID"].ToString();

                                strSql = " update usr_Rk_User_Link set ru_status='未阅知' where user_id in ( select usr_User.user_id from usr_read_know,usr_Rk_User_Link,usr_User where usr_User.user_id = usr_Rk_User_Link.user_id and usr_read_know.rk_id = usr_Rk_User_Link.Rk_id and usr_read_know.PRC_NAME = '" +
                                    strProcess + "' and usr_read_know.incident = " + strIncident + " and usr_read_know.step_name='" + strStepName + "') ";
                                int ret = sqlDb.exeSql(strSql);

                                strSql = "insert into usr_Rk_User_Link (Rk_ID,user_Id,ru_note,ru_status)  " +
                                    "select " + strRkID + ",user_id,'" + strSummary + "','未阅知' from usr_user " +
                                    "where user_code in (" + strGetUserId + ") and user_code not in " +
                                        "(select distinct usr_User.user_code from usr_read_know,usr_Rk_User_Link,usr_User " +
                                        "where usr_User.user_id = usr_Rk_User_Link.user_id and usr_read_know.rk_id = usr_Rk_User_Link.Rk_id " +
                                        "and usr_read_know.PRC_NAME = '" + strProcess + "' and usr_read_know.incident = " + strIncident +
                                        " and usr_read_know.step_name='" + strStepName + "')";

                                ret = sqlDb.exeSql(strSql);

                            }
                            else
                            {
                                strSql = " select user_id from usr_user where user_ult_code='" + sendUserID + "' ";
                                dt = sqlDb.GetDataTable(strSql);
                                if (dt.Rows.Count > 0)
                                {
                                    strSql = " insert into USR_READ_KNOW(PRC_NAME,STEP_NAME,INCIDENT,USER_ID,RK_DATE,TASK_ID) values('" +
                                        strProcess + "','" + strStepName + "'," + strIncident + "," + dt.Rows[0][0].ToString() + ",'" + DateTime.Now.ToString() +
                                        "','" + strTaskID + "') ";
                                    int ret = sqlDb.exeSql(strSql);
                                    //gw.Save<USR_READ_KNOW>(read);
                                    if (ret > 0)
                                    {
                                        strSql = "select Rk_ID from usr_read_know where Prc_Name='" + strProcess +
                                        "' and incident = " + strIncident;
                                        dt = sqlDb.GetDataTable(strSql);

                                        strSql = "insert into usr_Rk_User_Link (Rk_ID,user_Id,ru_note,ru_status)  " +
                                            "select " + dt.Rows[0][0].ToString() + ",user_id,'" + strSummary + "','未阅知' from usr_user " +
                                            "where user_code in (" + strGetUserId + ") ";
                                        //ret = gw.Db.ExecuteNonQuery(CommandType.Text, strSql);
                                        ret = sqlDb.exeSql(strSql);
                                    }
                                }
                            }
                        }

                    }
                    catch (Exception e)
                    {
                        // Log(this.LogPath, "InsertReadKnow：插入数据出错！" + e.Message.ToString() + strSql);
                    }
                    finally
                    {
                        if (sqlDb != null && sqlDb.Connection.State == System.Data.ConnectionState.Open)
                        {
                            sqlDb.clear();//关闭连接；
                        }
                    }
                }
            }
        }
            
        /// <summary>
        /// 赋值函数,将一个变量的值赋值给另一变量（可以是电子表格变量）
        /// </summary>
        /// <param name="SourceStr"></param>
        /// <param name="DestStr"></param>
        public void SetValue(string SourceStr, ref string DestStr)
        {
            DestStr = SourceStr;
        }

        /// <summary>
        /// 清空主变量的方法
        /// </summary>
        /// <param name="str1">要清空的数组</param>
        /// <param name="str2">要清空的字符串</param>
        public void setVal_null(ref string[] str1, ref string str2)
        {
            str1 = null;
            str2 = "";
        }

    }

    public class UltimusKeel
    {
        /// <summary>
        /// 实例化
        /// </summary>
        public UltimusKeel()
        {
            pvarList = new Variable[1];
        }

        //声明公共变量
        public Variable[] pvarList = null;
        public int pVarCount = -1;
        public Ultimus.WFServer.Task pTask = new Task();
        /// <summary>
        /// 实例化
        /// </summary>
        /// <param name="Count">输入的变量数</param>
        public UltimusKeel(int Count)
        {
            pvarList = new Variable[Count];
        }


        /// <summary>
        /// 实例化
        /// </summary>
        /// <param name="Count">输入的变量数</param>
        public UltimusKeel(int Count, string pTaskID)
        {
            pvarList = new Variable[Count];

            //初始化Task对象
            pTask.InitializeFromTaskId(pTaskID);
        }


        //初始化表结构
        public DataTable Blank()
        {
            DataTable pGetData = new DataTable();

            DataColumn pCol1 = new DataColumn("PROCESSNAME");//流程名称
            pGetData.Columns.Add(pCol1);

            DataColumn pCol2 = new DataColumn("SUMMARY");//摘要
            pGetData.Columns.Add(pCol2);

            DataColumn pCol3 = new DataColumn("INCIDENT");//实例号
            pGetData.Columns.Add(pCol3);

            DataColumn pCol4 = new DataColumn("VERSION");//流程版本
            pGetData.Columns.Add(pCol4);

            DataColumn pCol5 = new DataColumn("STEPNAME");//步骤名称
            pGetData.Columns.Add(pCol5);

            DataColumn pCol6 = new DataColumn("PRIORITY");//优先级
            pGetData.Columns.Add(pCol6);

            DataColumn pCol7 = new DataColumn("URGENTDUETIME");//完成时限
            pGetData.Columns.Add(pCol7);

            DataColumn pCol8 = new DataColumn("CLIENT");//当前用户
            pGetData.Columns.Add(pCol8);

            DataColumn pCol9 = new DataColumn("OWNER");//拥有者
            pGetData.Columns.Add(pCol9);

            DataColumn pCol10 = new DataColumn("STATUS");//状态
            pGetData.Columns.Add(pCol10);

            DataColumn pCol11 = new DataColumn("SUBSTATUS");//子状态
            pGetData.Columns.Add(pCol11);

            DataColumn pCol12 = new DataColumn("TASKID");//步骤ID
            pGetData.Columns.Add(pCol12);

            return pGetData;
        }

        //将符合条件的任务列表添加到数据表中
        public DataTable GetTaskListToDT(Ultimus.WFServer.Tasklist pTaskList)
        {
            DataTable pGetTaskData = this.Blank(); //初始化表结构

            if (pTaskList != null)
            {
                for (int i = 0; i < pTaskList.GetTasksCount(); i++)
                {
                    Ultimus.WFServer.Task pTask = pTaskList.GetAt(i);
                    DataRow pRow = pGetTaskData.NewRow();
                    pRow["PROCESSNAME"] = pTask.strProcessName;
                    pRow["SUMMARY"] = pTask.strSummary;
                    pRow["INCIDENT"] = pTask.nIncidentNo.ToString();
                    pRow["VERSION"] = pTask.nProcessVersion.ToString();
                    pRow["STEPNAME"] = pTask.strStepName;
                    pRow["PRIORITY"] = pTask.nPriority.ToString();
                    pRow["URGENTDUETIME"] = DateTime.FromOADate(pTask.dOverDueTime);
                    pRow["CLIENT"] = pTask.strAssignedToUser;
                    pRow["OWNER"] = pTask.strUser;
                    pRow["STATUS"] = pTask.nTaskStatus;
                    pRow["SUBSTATUS"] = pTask.nTaskSubStatus;
                    pRow["TASKID"] = pTask.strTaskId;

                    pGetTaskData.Rows.Add(pRow);
                }
            }

            return pGetTaskData;
        }


        /// <summary>
        /// 添加变量
        /// </summary>
        /// <param name="varName">变量名称</param>
        /// <param name="varValue">变量值</param>
        /// <returns></returns>
        public bool AddVariable(string varName, string varValue)
        {
            bool pReturn = false;

            try
            {
                pVarCount += 1;
                Variable pvar = new Variable();
                pvar.strVariableName = varName;
                pvar.objVariableValue = new object[] { varValue };
                pvarList.SetValue(pvar, pVarCount);

                pReturn = true;
            }
            catch
            {
                pReturn = false;
            }
            return pReturn;
        }


        /// <summary>
        /// 添加多值变量
        /// </summary>
        /// <param name="varName">变量名称</param>
        /// <param name="varValue">变量值 对象数组</param>
        /// <returns></returns>
        public bool AddVariable(string varName, object[] varValue)
        {
            bool pReturn = false;

            try
            {
                pVarCount += 1;
                Variable pvar = new Variable();
                pvar.strVariableName = varName;
                pvar.objVariableValue = varValue;
                pvarList.SetValue(pvar, pVarCount);

                pReturn = true;
            }
            catch
            {
                pReturn = false;
            }
            return pReturn;
        }


        /// <summary>
        /// 添加多值变量
        /// </summary>
        /// <param name="varName">变量名称</param>
        /// <param name="varValue">变量值字符串数组</param>
        /// <returns></returns>
        public bool AddVariable(string varName, string[] varValue)
        {
            bool pReturn = false;

            try
            {
                pVarCount += 1;
                Variable pvar = new Variable();
                pvar.strVariableName = varName;
                pvar.objVariableValue = varValue;
                pvarList.SetValue(pvar, pVarCount);

                pReturn = true;
            }
            catch
            {
                pReturn = false;
            }
            return pReturn;
        }

        /// <summary>
        /// 添加多值变量
        /// </summary>
        /// <param name="varName">变量名称</param>
        /// <param name="varValue">变量值 数据集</param>
        /// <param name="pColName">数据集列名</param>
        /// <returns></returns>
        public bool AddVariable(string varName, DataTable pDataTable, string pColName)
        {
            bool pReturn = false;

            try
            {
                int pCount = pDataTable.Rows.Count;
                object[] varValue = new object[pCount];
                for (int i = 0; i < pCount; i++)
                {
                    varValue[i] = pDataTable.Rows[i][pColName].ToString();
                }

                pVarCount += 1;
                Variable pvar = new Variable();
                pvar.strVariableName = varName;
                pvar.objVariableValue = varValue;
                pvarList.SetValue(pvar, pVarCount);

                pReturn = true;
            }
            catch
            {
                pReturn = false;
            }
            return pReturn;
        }


        /// <summary>
        /// 添加多值变量
        /// </summary>
        /// <param name="varName">变量名称</param>
        /// <param name="pDataTable">变量数据集</param>
        /// <returns></returns>
        public bool AddVariable(string varName, DataTable pDataTable)
        {
            bool pReturn = false;

            try
            {
                int pCount = pDataTable.Rows.Count;
                object[] varValue = new object[pCount];
                for (int i = 0; i < pCount; i++)
                {
                    varValue[i] = pDataTable.Rows[i][0].ToString();
                }

                pVarCount += 1;
                Variable pvar = new Variable();
                pvar.strVariableName = varName;
                pvar.objVariableValue = varValue;
                pvarList.SetValue(pvar, pVarCount);

                pReturn = true;
            }
            catch
            {
                pReturn = false;
            }
            return pReturn;
        }

        //退回步骤的方法
        #region MyRegion
        public bool ReturnStep(string pTaskId, string strSummary, string strMemo, Variable[] varList, out string strError)
        {
            bool flag1 = false;
            strError = "";
            try
            {
                Task task1 = new Task();
                task1.InitializeFromTaskId(pTaskId);
                if (task1 == null)
                {
                    strError = "No task for these parameters";
                    return false;
                }
                if (task1.Return(varList, strMemo, strSummary, out strError))
                {
                    return true;
                }
                flag1 = false;
            }
            catch (Exception exception1)
            {
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }

        public bool ReturnStep(string strProcessName, string strUserName, int nIncidentNumber, string strStepName, string strSummary, string strMemo, Variable[] varList, out string strError)
        {
            bool flag1;
            Tasklist tasklist1 = new Tasklist();
            TasklistFilter filter1 = new TasklistFilter();
            Task task1 = new Task();
            try
            {
                filter1.strProcessNameFilter = strProcessName;
                filter1.strStepLabelFilter = strStepName;
                filter1.nIncidentNo = nIncidentNumber;
                filter1.strArrUserName = new string[1] { strUserName };
                tasklist1.LoadFilteredTasks(filter1);
                task1 = tasklist1.GetFirstTask();
                if (task1 == null)
                {
                    strError = "No task for these parameters";
                    return false;
                }
                if (task1.Return(varList, strMemo, strSummary, out strError))
                {
                    return true;
                }
                flag1 = false;
            }
            catch (Exception exception1)
            {
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }

        #endregion

        //取消实例的方法
        public bool AbortIncident(string strProcessName, string strSummary,string strUserName,  int nIncidentNumber,  out string strError)
        {
            //string strUserName="BPM/2948";
            //string strSummary="流程错误";
            bool flag1;
            
            Incident incident1 = new Incident();
            try
            {
                incident1.LoadIncident(strProcessName, nIncidentNumber);
                if (incident1.AbortIncident(strUserName, strSummary, out strError))
                {
                    //incident1.AbortIncident (
                    return true;
                }
                flag1 = false;
            }
            catch (Exception exception1)
            {
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }

        //不用了可以使用下面的两个方法来替代】
        public bool CompleteStep(string strProcessName, string strUserName, ref int nIncidentNumber, string strStepName, string strSummary, string strMemo, Variable[] varList, out string strError)
        {
            bool flag1;
            Tasklist tasklist1 = new Tasklist();
            TasklistFilter filter1 = new TasklistFilter();
            Task task1 = new Task();
            try
            {
                //int num1=-1;
                filter1.strProcessNameFilter = strProcessName;
                filter1.strStepLabelFilter = strStepName;
                filter1.nIncidentNo = nIncidentNumber;
                filter1.strArrUserName = new string[1] { strUserName };
                tasklist1.LoadFilteredTasks(filter1);
                task1 = tasklist1.GetFirstTask();
                if (task1 == null)
                {
                    strError = "No task for these parameters";
                    return false;
                }
                if (task1.Send(varList, strMemo, strSummary, ref nIncidentNumber, out strError))
                {
                    return true;
                }
                flag1 = false;
            }
            catch (Exception exception1)
            {
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }

        /// <summary>
        /// 提交步骤时使用（除开始步骤）
        /// </summary>
        /// <param name="pTaskID">任务id</param>
        /// <param name="pVarList">变量数组</param>
        /// <returns></returns>
        public bool Send(string pTaskID, Ultimus.WFServer.Variable[] pVarList)
        {
            bool pReturn = false;
            int nincident = 0;
            string strError = "";
            try
            {
                Ultimus.WFServer.Task ptask = new Ultimus.WFServer.Task();
                bool pBool = ptask.InitializeFromTaskId(pTaskID);

                if (pBool)
                {
                    string summy = ptask.strSummary.ToString();
                    pReturn = ptask.Send(pVarList, "", summy, ref nincident, out strError);
                }
            }
            catch (Exception exception1)
            {
                nincident = -1;
                strError = exception1.Message;
                pReturn = false;
            }

            return pReturn;
        }

        /// <summary>
        /// 提交步骤时使用（退回到开始步骤时）
        /// </summary>
        /// <param name="pTaskID">任务id</param>
        /// <param name="pVarList">变量数组</param>
        /// <returns></returns>
        public bool Send2(string pTaskID,string summy, Ultimus.WFServer.Variable[] pVarList)
        {
            bool pReturn = false;
            int nincident = 0;
            string strError = "";
            try
            {
                Ultimus.WFServer.Task ptask = new Ultimus.WFServer.Task();
                bool pBool = ptask.InitializeFromTaskId(pTaskID);

                if (pBool)
                {
                   
                    pReturn = ptask.Send(pVarList, "", summy, ref nincident, out strError);
                }
            }
            catch (Exception exception1)
            {
                nincident = -1;
                strError = exception1.Message;
                pReturn = false;
            }

            return pReturn;
        }
        //发起流程时使用的方法（开始步骤）
        public bool LaunchIncident(string strProcessName, string strUserName, string strSummary, Variable[] varList, ref int nIncidentNo, out string strError)
        {
           
            bool flag1;
            Tasklist tasklist1 = new Tasklist();
            TasklistFilter filter1 = new TasklistFilter();
            Task task1 = new Task();
            try
            {
                nIncidentNo = -1;

                filter1.strProcessNameFilter = strProcessName;
                filter1.nIncidentNo = 0;
                filter1.strArrUserName = new string[1] { strUserName };
                tasklist1.LoadFilteredTasks(filter1);
                task1 = tasklist1.GetFirstTask();
                if (task1 == null)
                {
                    //nIncidentNo = -1;
                    strError = "No task for these parameters";
                    return false;
                }
                //task1.strRecipient = strUserName;
                if (task1.Send(varList, "", strSummary, ref  nIncidentNo, out strError))
                {
                    return true;
                }
                flag1 = false;
            }
            catch (Exception exception1)
            {
                nIncidentNo = -1;
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }

        //获取流程发起步骤的变量的集合
        public bool GetLaunchInformation(string strProcessName, string strUserName, out Variable[] varList, out string strError)
        {
            bool flag1;
            Tasklist tasklist1 = new Tasklist();
            TasklistFilter filter1 = new TasklistFilter();
            Task task1 = new Task();
            try
            {
                filter1.strProcessNameFilter = strProcessName;
                filter1.nIncidentNo = 0;
                filter1.strArrUserName = new string[1] { strUserName };
                tasklist1.LoadFilteredTasks(filter1);
                task1 = tasklist1.GetFirstTask();
                if (task1 == null)
                {
                    strError = "No task for these parameters";
                    varList = null;
                    return false;
                }
                if (task1.GetAllTaskVariables(out varList, out strError))
                {
                    return true;
                }
                varList = null;
                flag1 = false;
            }
            catch (Exception exception1)
            {
                varList = null;
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }

        //获取任务的所有变量的方法
        #region
        public bool GetTaskInformation(string pTaskID, out Variable[] varList, out string strError)
        {
            bool pReturn = false;
            varList = null;
            strError = "";
            Ultimus.WFServer.Task ptask1 = new Ultimus.WFServer.Task();
            bool pBool = ptask1.InitializeFromTaskId(pTaskID);
            if (pBool)
            {
                if (ptask1.GetAllTaskVariables(out varList, out strError))
                {
                    return true;
                }
            }
            return pReturn;
        }
        public bool GetTaskInformation(string strProcessName, string strUserName, int nIncidentNumber, string strStepName, out Variable[] varList, out string strError)
        {
            bool flag1;
            Tasklist tasklist1 = new Tasklist();
            TasklistFilter filter1 = new TasklistFilter();
            Task task1 = new Task();
            try
            {
                filter1.strProcessNameFilter = strProcessName;
                filter1.strStepLabelFilter = strStepName;
                filter1.nIncidentNo = nIncidentNumber;
                filter1.strArrUserName = new string[1] { strUserName };
                tasklist1.LoadFilteredTasks(filter1);
                task1 = tasklist1.GetFirstTask();
                if (task1 == null)
                {
                    strError = "No task for these parameters";
                    varList = null;
                    return false;
                }
                if (task1.GetAllTaskVariables(out varList, out strError))
                {
                    return true;
                }
                varList = null;
                flag1 = false;
            }
            catch (Exception exception1)
            {
                varList = null;
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }

        #endregion

        //获取任务的状态
        #region
        public bool GetTaskStatus(string pTaskID, out int pStatus, out string strError)
        {
            bool flag = false;
            pStatus = -1;
            strError = "";

            Ultimus.WFServer.Task pTask1 = new Task();
            bool pBool = pTask1.InitializeFromTaskId(pTaskID);
            if (pBool)
            {
                pStatus = pTask1.nTaskStatus;
                strError = "";
                flag = true;
            }
            return flag;
        }

        public bool GetTaskStatus(string strProcessName, string strUserName, int nIncidentNumber, string strStepName, out int pStatus, out string strError)
        {

            bool flag1;
            pStatus = -1;
            Tasklist tasklist1 = new Tasklist();
            TasklistFilter filter1 = new TasklistFilter();
            Task task1 = new Task();
            try
            {
                filter1.strProcessNameFilter = strProcessName;
                filter1.strStepLabelFilter = strStepName;
                filter1.nIncidentNo = nIncidentNumber;
                filter1.strArrUserName = new string[1] { strUserName };
                tasklist1.LoadFilteredTasks(filter1);
                task1 = tasklist1.GetFirstTask();
                if (task1 == null)
                {
                    strError = "No task for these parameters";
                    return false;
                }

                pStatus = task1.nTaskStatus;
                strError = "";
                flag1 = true;
            }
            catch (Exception exception1)
            {
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }
        #endregion


        /// <summary>
        /// 获取可发起、代办任务、已完成任务列表
        /// </summary>
        /// <param name="strUserName">用户账号(域名\账号)</param>
        /// <param name="nType">1-可发起流程 2-代办 3-已完成</param>
        /// <param name="pGetTaskData">返回流程的数据集</param>
        /// <param name="strError">返回错误</param>
        /// <returns></returns>
        public bool GetUserTasksList(string strUserName, int nType, out DataTable pGetTaskData, out string strError)
        {
            bool flag1;
            Tasklist tasklist1 = new Tasklist();
            TasklistFilter filter1 = new TasklistFilter();
            Task task1 = new Task();

            pGetTaskData = null;
            try
            {
                //filter1.strProcessNameFilter = strProcessName;
                filter1.strArrUserName = new string[1] { strUserName };

                switch (nType)
                {
                    case 1:
                        filter1.nFiltersMask = Filters.nFilter_Initiate;
                        break;
                    case 2:
                        filter1.nFiltersMask = (Filters.nFilter_Urgent | Filters.nFilter_Overdue) | Filters.nFilter_Current;
                        break;
                    case 3:
                        filter1.nFiltersMask = Filters.nFilter_Complete;
                        break;
                }
                tasklist1.LoadFilteredTasks(filter1);

                pGetTaskData = this.GetTaskListToDT(tasklist1);

                strError = null;
                flag1 = true;
            }
            catch (Exception exception1)
            {
                tasklist1 = null;
                strError = exception1.Message;
                flag1 = false;
            }
            return flag1;
        }

        /// <summary>
        /// 获取变量值
        /// </summary>
        /// <param name="pTask"></param>
        /// <param name="varName"></param>
        /// <returns></returns>
        public string GetVarValue(Ultimus.WFServer.Task pTask, string varName)
        {
            string strError = "";
            object pretValue = "";
            pTask.GetVariableValue(varName, out pretValue, out strError);

            return pretValue.ToString();
        }

        /// <summary>
        /// 退回
        /// </summary>
        /// <param name="pTaskID"></param>
        /// <param name="pVarList"></param>
        /// <returns></returns>
        public bool Return(string pTaskID, Ultimus.WFServer.Variable[] pVarList)
        {
            bool pReturn = false;
            Ultimus.WFServer.Task ptask = new Ultimus.WFServer.Task();
            bool pBool = ptask.InitializeFromTaskId(pTaskID);
            if (pBool)
            {
                //int nincident = 0;
                string strError = "";
                pReturn = ptask.Return(pVarList, "", "", out strError);
            }
            return pReturn;
        }
    }
    #region windows事件类
    //window事件日志类
    public class UltimusWindowEventLog
    {
        public UltimusWindowEventLog()
        {

        }
        private string GetConfig(string StrTemp)
        {
            System.Data.DataSet Ds = new System.Data.DataSet();
            try
            {
                Ds.ReadXml(@"C:\Program Files\Ultimus BPM Suite 7.1\Resources\Config.xml");
                if (Ds != null && Ds.Tables["setItem"].Rows.Count > 0)
                {
                    return (Ds.Tables["setItem"].Rows[0][StrTemp].ToString());
                }
                else
                {
                    EventLog.WriteEntry("UltimusEventLog", "GetConfig：服务组件读取\"" + StrTemp + "\"信息失败！");
                    return "2";
                }
            }
            catch (Exception ee)
            {
                EventLog.WriteEntry("UltimusEventLog", "GetConfig：" + ee.Message);
                return "2";
            }
        }

        // 0:错误；1：信息；2:信息+调试；

        public void Info(string strFileName, string strFunction, string strMsg)
        {
            try
            {
                string strTemp = GetConfig("LogMode");
                if (strTemp == "0")
                {
                    return;
                }
                EventLog.WriteEntry("UltimusEventLog", "FileName(" + strFileName + "),Function(" + strFunction + "),Info:" + strMsg);
            }
            catch (Exception ee)
            {
                EventLog.WriteEntry("UltimusEventLog", "FileName：" + ee.Message);
            }
        }
        public void Error(string strFileName, string strFunction, string strMsg)
        {
            try
            {
                EventLog.WriteEntry("UltimusEventLog", "FileName(" + strFileName + "),Function(" + strFunction + "),Error:" + strMsg);
            }
            catch (Exception ee)
            {
                EventLog.WriteEntry("UltimusEventLog", "Error：" + ee.Message);
            }
        }

        public void Debug(string strFileName, string strFunction, string strMsg)
        {
            try
            {
                string strTemp = GetConfig("LogMode");
                if (strTemp == "0" || strTemp == "1") { return; }
                EventLog.WriteEntry("UltimusEventLog", "FileName(" + strFileName + "),Function(" + strFunction + "),Debug:" + strMsg);
            }
            catch (Exception ee)
            {
                EventLog.WriteEntry("UltimusEventLog", "Debug：" + ee.Message);
            }
        }
    }
    #endregion

    #region Sql操作类；
    public class SqlDBClass
    {
        /*----全局变量定义------*/

        private SqlConnection conn;
        private SqlCommand comm;
        private string connStr;   /* 数据库联接字符串 */
        public string errInfo = "";
        //static log4net.ILog _logEik = log4net.LogManager.GetLogger(typeof(BLLUltimusEik));
        /*----------------------*/
        //无参数构造函数
        public SqlDBClass()
        {
            connStr = "";
        }
        /// <summary>
        /// 获得链接字符串
        /// </summary>
        /// <param name="ConnString">链接字符串标识</param>
        public void GetConString(string ConnString)
        {
            connStr = ConnString;
        }
        /// <summary>
        /// 有参数构造函数
        /// </summary>
        /// <param name="ConnString">链接字符串</param>
        public SqlDBClass(string ConnString)
        {
            connStr = ConnString;
        }
        /* 数据库操作异常信息 只读属性 */
        public string ErrInfo
        {
            get
            {
                return errInfo;
            }
        }

        /* 数据库链接字符串 */
        public string ConnStr
        {
            get
            {
                return connStr;
            }
            set
            {
                connStr = value;
            }
        }
        private void connDb()
        {
            try
            {
                if (conn == null || conn.State == ConnectionState.Closed)
                {
                    conn = new SqlConnection(connStr);
                    conn.Open();
                }
            }
            catch (Exception e)
            {
                errInfo = e.Message;
                conn.Close();
            }
        }

        /* 数据库链接字符串 */
        public SqlConnection Connection
        {
            get
            {
                return conn;
            }
            set
            {
                conn = value;
            }
        }

        /// <summary>
        /// 产生数据库链接对象，并打开链接
        /// </summary>
        /// <returns>返回链接SqlConnection </returns>
        public SqlConnection getConnect()
        {
            SqlConnection Connection = null;
            try
            {
                if (conn == null || conn.State == ConnectionState.Closed)
                {
                    conn = new SqlConnection(connStr);
                    conn.Open();

                    Connection = conn;
                }
            }
            catch (Exception e)
            {
                errInfo = e.Message;
                conn.Close();

            }

            return Connection;
        }

        /* 获取DataSet */
        /// <summary>
        /// 获取数据集
        /// </summary>
        /// <param name="sql">入参查询语句</param>
        /// <returns>返回DataSet</returns>
        public DataSet GetDataSet(string sql)
        {
            connDb();
            SqlDataAdapter dad = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            dad.Fill(ds);
            this.clear();
            return ds;
        }
        /// <summary>
        /// 获取数据集
        /// </summary>
        /// <param name="sql">入参查询语句</param>
        /// <param name="Connection">数据库链接对象</param>
        /// <returns></returns>
        public DataSet GetDataSet(string sql, SqlConnection Connection)
        {
            conn = Connection;
            SqlDataAdapter dad = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            dad.Fill(ds);
            return ds;
        }

        /* 获取DataTable */
        /// <summary>
        /// 获取数据表
        /// </summary>
        /// <param name="sql">入参查询语句</param>
        /// <returns>返回DataTable</returns>
        public DataTable GetDataTable(string sql)
        {

            connDb();
            SqlDataAdapter dad = new SqlDataAdapter(sql, conn);
            //_logEik.Error("sql=" + sql);
            DataSet ds = new DataSet();
            dad.Fill(ds);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                {
                    this.clear();
                    return ds.Tables[0];
                }
                else
                {
                    this.clear();
                    return null;
                }
            }
            else
            {
                this.clear();
                return null;
            }
        }
        /* 执行SQL语句，返回结果 */
        /// <summary>
        /// 获取SqlDataReader
        /// </summary>
        /// <param name="sql">入参查询语句</param>
        /// <returns>返回SqlDataReader</returns>
        public SqlDataReader readerDataReader(string sql)
        {
            connDb();
            comm = new SqlCommand(sql, conn);
            SqlDataReader dr = comm.ExecuteReader();

            return dr;
        }
        /// <summary>
        /// 获取数据表
        /// </summary>
        /// <param name="sql">入参查询语句</param>
        /// <param name="Connection">数据库链接对象</param>
        /// <returns>返回DataTable</returns>
        public DataTable GetDataTable(string sql, SqlConnection Connection)
        {
            conn = Connection;

            SqlDataAdapter dad = new SqlDataAdapter(sql, conn);
            DataSet ds = new DataSet();
            dad.Fill(ds);

            if (ds != null)
            {
                if (ds.Tables.Count > 0)
                    return ds.Tables[0];
                else
                    return null;
            }
            else
                return null;
        }

        /* 执行SQL语句，不返回结果 */
        /// <summary>
        ///  执行SQL语句
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <returns>影响的行数，</returns>
        public int exeSql(string sql)
        {
            try
            {
                connDb();
                comm = new SqlCommand(sql, conn);
                int pReturn = comm.ExecuteNonQuery();
                this.clear();
                return pReturn;
            }
            catch (Exception e)
            {
                errInfo = e.Message;
                this.clear();
                return 0;
            }
        }
        /* 执行SQL语句，不返回结果 */
        /// <summary>
        ///  执行SQL语句
        /// </summary>
        /// <param name="sql">sql语句</param>
        /// <param name="Connection">数据库链接对象</param>
        /// <returns>影响的行数，</returns>
        public int exeSql(string sql, SqlConnection Connection)
        {
            try
            {
                conn = Connection;
                comm = new SqlCommand(sql, conn);
                int pReturn = comm.ExecuteNonQuery();
                return pReturn;
            }
            catch (Exception e)
            {
                errInfo = e.Message;
                this.clear();
                return 0;
            }
        }
        /* 关闭链接 */
        public void clear()
        {
            if (conn.State == ConnectionState.Open)
            {
                conn.Close();
            }
        }
    }
    #endregion
}
